const typesDict = [
	{
		label: '白天（6:00至20:00）',
		value: '1',
	},
	{
		label: '夜间(20:00至6:00）',
		value: '2',
	},
	{
		label: '白天和夜间(0:00至24:00)',
		value: '3',
	},
]
export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '巡查频次(天)',
			prop: 'frequency',
			type: 'input',
			span: 24,
			rules: [{ required: true, message: '请输入巡查频次(天)' }],
		},
		{
			label: '巡查类型',
			prop: 'types',
			propName: 'typesLabel',
			type: 'remoteSelect',
			multiple: true,
			remote: false,
			dicData: typesDict,
			rules: [{ required: true, message: '请选择巡查类型' }],
			span: 24,
		},
		{
			label: '启用状态',
			prop: 'status',
			type: 'select',
			dicData: [
				{
					label: '启用',
					value: 1,
				},
				{
					label: '禁用',
					value: 2,
				},
			],
			rules: [{ required: true, message: '请选择启用状态' }],
			span: 24,
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '巡查频次(天)',
			prop: 'frequency',
			type: 'input',
			span: 8,
		},
		{
			label: '巡查类型',
			prop: 'types',
			type: 'select',
			dicData: typesDict,
			span: 8,
		},
		{
			label: '启用状态',
			prop: 'status',
			type: 'select',
			dicData: [
				{
					label: '启用',
					value: 1,
				},
				{
					label: '禁用',
					value: 2,
				},
			],
			span: 8,
		},
		{
			label: '创建时间',
			prop: 'createTimeBetween',
			type: 'dateBetween',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '巡查频次(天)', prop: 'frequency' },
		{
			label: '巡查类型',
			prop: 'types',
			custome: 'tag',
			dicData: typesDict,
		},
		{
			label: '启用状态',
			prop: 'status',
			custome: 'tag',
			dicData: [
				{
					label: '启用',
					value: 1,
					type: 'success',
				},
				{
					label: '禁用',
					value: 2,
					type: 'danger',
				},
			],
			span: 8,
		},
		{ label: '创建人', prop: 'createUserName' },
		{ label: '创建时间', prop: 'createTime' },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_setDailyFireInspectionRules_page',
	add: 'view_setDailyFireInspectionRules_add',
	edit: 'view_setDailyFireInspectionRules_edit',
	delete: 'view_setDailyFireInspectionRules_del',
}
export const baseConfig = {
	pageName: '日常防火巡查规则',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'frequency',
	exportMqTopic: '/ning/export/',
	api,
	auth: api,
	paramsObj: {
		source: 1,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: api.edit,
			text: true,
			show: true,
		},
		{
			icon: 'detail',
			label: '详情',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: api.delete,
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '55%',
	},
	searchConfig,
	formConfig,
	tableConfig,
	detailConfig: formConfig,
	onLoadFormate: async (arr) => {
		return Promise.resolve(
			arr.map((item) => {
				const dict = typesDict
					.filter((i) => item.types.includes(i.value))
					.map((i) => i.label)
					.join(',')

				return {
					...item,
					typesLabel: dict ? dict : item.types,
				}
			})
		)
	},
}
